<?php

/**
 * Usuario form base class.
 *
 * @package    form
 * @subpackage usuario
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseUsuarioForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'perfil_id'      => new sfWidgetFormDoctrineChoice(array('model' => 'Perfil', 'add_empty' => true)),
      'familia_id'     => new sfWidgetFormDoctrineChoice(array('model' => 'Familia', 'add_empty' => true)),
      'login'          => new sfWidgetFormInput(),
      'password'       => new sfWidgetFormInput(),
      'email'          => new sfWidgetFormInput(),
      'estado'         => new sfWidgetFormInput(),
      'last_access_at' => new sfWidgetFormDateTime(),
      'slug'           => new sfWidgetFormInput(),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_at'     => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorDoctrineChoice(array('model' => 'Usuario', 'column' => 'id', 'required' => false)),
      'perfil_id'      => new sfValidatorDoctrineChoice(array('model' => 'Perfil', 'required' => false)),
      'familia_id'     => new sfValidatorDoctrineChoice(array('model' => 'Familia', 'required' => false)),
      'login'          => new sfValidatorString(array('max_length' => 100)),
      'password'       => new sfValidatorString(array('max_length' => 255)),
      'email'          => new sfValidatorString(array('max_length' => 100)),
      'estado'         => new sfValidatorString(array('max_length' => 1)),
      'last_access_at' => new sfValidatorDateTime(array('required' => false)),
      'slug'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'created_at'     => new sfValidatorDateTime(array('required' => false)),
      'updated_at'     => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Usuario', 'column' => array('login'))),
        new sfValidatorDoctrineUnique(array('model' => 'Usuario', 'column' => array('slug'))),
      ))
    );

    $this->widgetSchema->setNameFormat('usuario[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Usuario';
  }

}
